-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[WIP] cURL Socket Functions #19656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[WIP] cURL Socket Functions #19656
Conversation
php_stream *p_stream; | ||
|
||
if (stream == NULL && what != CURL_POLL_REMOVE) { | ||
p_stream = (void*) php_stream_fopen_from_fd(socket, "rw", NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be read only.
48ebc7b
to
5842e34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is reasonable to add support for curl_multi_socket_action but as mentioned in the comment, I don't think it should be using streams at all.
php_stream *p_stream; | ||
|
||
if (stream == NULL && what != CURL_POLL_REMOVE) { | ||
p_stream = (void*) php_stream_fopen_from_fd(socket, "rw", NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, it's the best idea to use streams just a pure fd wrapper. In this case I would just use zend_long to contain it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically the only purpose of the fd here is to be able to pass it to the polling mechanism and then call curl_multi_socket_action
when ready so it should not be used for reading / writing by stream. If users want to use stream_select for polling then they should be able to do conversion using php://fd/$socketfd
. That said I plan to look to an easier way how use pure fd in stream_select and the new polling API so this should get even easier in the future.
So, it looks most reasonable/elegant to wait for the new polling api so that we don't have to decorate the socket as a stream internally or externally. |
A request was made to expose cURL sockets to userland so they may be used in external event loops.
The original request suggested we use curls export of fdsets, this looked pretty restricted though when I came to implement it, and exporting the set for every select also didn't look very performant.
cURL has provided these API's for a long time, a very long time, and we have never implemented them, I'm not certain of the reasons for that.
This has reintroduced resources in cURL, but there's no other reasonable way to do this ...
To opt-in to socket management you must set a timer and socket function.
I'm not certain about this at all, looking for feedback on this approach.
I'm not certain of the consequences of manipulating these streams outside of select(), what happens if you read or write them is unclear.